import service from '@/utils/request'
import request from '@/utils/request'
import utils from '@/utils/util'

const merchantApi = {

  // 商户码表
  getSetting(data) {
    return request({
      url: '/api/inner/portal/setting/list?codeType=' + data,
      method: 'get'
    })
  },

  // 充值金额
  postMerchantMoney(data) {
    return request({
      url: '/api/inner/portal/charge',
      method: 'post',
      data: data
    })
  },

  // 根据传入的条件查询充值内容
  getMerchantMoney(data) {
    return request({
      url: '/api/inner/portal/charges',
      method: 'post',
      data: data
    })
  },

  // 商户列表
  getMerchantList(params) {
    return request({
      url: '/api/inner/portal/merchant',
      method: 'post',
      data: params
    })
  },

  // 单个商户
  getMerchant(params) {
    return request({
      url: '/api/inner/portal/merchant/' + params,
      method: 'get'
    })
  },

  dataNode() {
    return request({
      url: '/api/inner/portal/merchant/dataNode',
      method: 'get'
    })
  },

  // 更新商户
  putMerchant(params) {
    return request({
      url: '/api/inner/portal/merchant',
      method: 'put',
      data: params
    })
  },

  // 管理员信息
  getAdminInfo(params) {
    return request({
      url: '/api/inner/portal/merchant/' + params.merchantUserAccount + '/' + params.tenantcode + '/userInfo',
      method: 'get'
    })
  },

  // 保存管理员
  saveAdminInfo(params) {
    return request({
      url: '/api/inner/portal/merchant/userInfo',
      method: 'post',
      data: params
    })
  },

  // 权限信息
  getAuthInfo(params) {
    return request({
      url: '/api/inner/portal/merchant/' + params + '/productAuth',
      method: 'get'
    })
  },

  // 保存权限
  saveAuthInfo(params) {
    return request({
      url: '/api/inner/portal/merchant/productAuth',
      method: 'post',
      data: params
    })
  },

  // 用户管理

  // 查询列表(分页)
  getUserListByPage(data) {
    const params = utils.dealGetData(data)
    return service.get('/api/inner/tenant/user/list' + params)
  },

  // 查询详情
  getUserDetail(data) {
    return service.get('/api/inner/tenant/user/' + data)
  },

  // 用户区域
  getUserAreaList() {
    return service.get('/api/inner/tenant/getAreaList')
  },

  // 用户门店
  getStoreList(data) {
    const params = utils.dealGetData(data)
    // return service.get("/tenant/getStoreList" + params)
    return service.get('/api/inner/menu/menuTemplateStoresChoose/storeLists' + params)
  },

  getBatchGetStoreList(menuTemplateStoresVo) {
    return service.post('/api/inner/menu/menuTemplateStoresChoose/toStoreLists', menuTemplateStoresVo)
  },

  // 新增用户
  addUser(data) {
    return service.post('/api/inner/tenant/user/save', data)
  },

  // 修改用户
  updateUser(data) {
    return service.put('/api/inner/tenant/user/save', data)
  },

  // 禁用或解禁
  updateStatus(data) {
    return service.put('/api/inner/tenant/user/status', data)
  },

  // 角色列表
  getRolesList(data) {
    const params = utils.dealGetData(data)
    return service.get('/api/inner/tenant/roles' + params)
  },

  // 已选择角色
  getRoleById(id) {
    return service.get('/api/inner/tenant/' + id + '/roles')
  },

  // 保存已选角色
  saveRole(data) {
    return service.post('/api/inner/tenant/user/roles', data)
  },

  // 密码重置
  resetPwd(data) {
    return service.put('/api/inner/tenant/user/resetPassword', data)
  },

  // 商户详情查看
  getAllMerchant(data) {
    const params = utils.dealGetData(data)
    return service.get('/api/inner/portal/merchant/info' + params)
  }

}

export default merchantApi
